//系统方案
#include<stdio.h>
#include<errno.h>
#include<string.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#define LOG_NORMAL "logNormal.txt"
#define LOG_ERROR "logError.txt"

int main()
{
  fprintf(stdout,"hello fprintf\n");
  const char*msg="hello write\n";
  write(1,msg,strlen(msg));
  fork();
  return 0;
}







/*int main()
{
  int fd=open(LOG_NORMAL,O_CREAT|O_WRONLY|O_APPEND,0666);
  if(fd<0)
  {
    perror("open");
    return 1;
  }
  dup2(fd,1);
  printf("hello world,hello bit!\n");
  close(fd);
  return 0;
}*/
/*int main()
{
 close(1);
 open(LOG_NORMAL,O_WRONLY|O_CREAT|O_APPEND,0666);
 printf("hello printf->stdout\n");
 printf("hello printf->stdout\n");
 printf("hello printf->stdout\n");
 printf("hello printf->stdout\n");
 fprintf(stdout,"hello fprintf->stdout\n");
 fprintf(stdout,"hello fprintf->stdout\n");
 fprintf(stdout,"hello fprintf->stdout\n");
 fprintf(stdout,"hello fprintf->stderr\n");
 fprintf(stdout,"hello fprintf->stdout\n");
 fprintf(stdout,"hello fprintf->stdout\n");
 fprintf(stdout,"hello fprintf->stdout\n");
  return 0;
}*/
/*int main()
{
  printf("%d\n",stdin->_fileno);
  printf("%d\n",stdout->_fileno);
  printf("%d\n",stderr->_fileno);
  FILE*fp=fopen(LOG,"w");
  printf("%d\n",fp->_fileno);
  return 0;
}
*/








//int main()
//{
 // int fd=open(LOG,O_WRONLY);
///  if(fd==-1)
 // {
  ///  printf("fd:%s,error:%d,errstring:%s\n",fd,errno,strerror(errno));
 /// }
 // close(fd);
 // return 0;
///}
/*int main()
{
 close(0);
  int fd1=open(LOG,O_WRONLY| O_CREAT|O_TRUNC,0666);
  int fd2=open(LOG,O_WRONLY| O_CREAT|O_TRUNC,0666);
  int fd3=open(LOG,O_WRONLY| O_CREAT|O_TRUNC,0666);
  int fd4=open(LOG,O_WRONLY| O_CREAT|O_TRUNC,0666);
  int fd5=open(LOG,O_WRONLY| O_CREAT|O_TRUNC,0666);
  int fd6=open(LOG,O_WRONLY| O_CREAT|O_TRUNC,0666);
  printf("%d\n",fd1);
  printf("%d\n",fd2);
  printf("%d\n",fd3);
  printf("%d\n",fd4);
  printf("%d\n",fd5);
  printf("%d\n",fd6);*/
 /* close(1);
  int fd=open(LOG,O_WRONLY|O_CREAT|O_APPEND,0666);
  printf("you can see\n");
  printf("you can see\n");
  printf("you can see\n");
  printf("you can see\n");
  printf("you can see\n");
  printf("you can see\n");*/
 /* close(0);
  int fd=open(LOG,O_WRONLY);
  int a,b;
  scanf("%d %d",&a,&b);
  printf("a=%d,b=%d\n",a,b);
  return 0;
}*/














//bi/n/#include<stdio.h>
//#define LOG "log.txt"
//int main()
//{
//  FILE*fp=fopen(LOG,"w");
//  if(fp==NULL)
//  {
//    perror("fopen");
//    return 1;
//  }
//  while(1)
//  {
//va//r/var/    char line[128];
//    if(fgets(line,sizeof(line),fp)==NULL)break;
//    else printf("%s\n",line);
//  }
 // const char*msg="hello xiaolu,hello 107";
 // int cnt=5;
 // while(cnt)
 // {
 //   char buffer[256];
 //   snprintf(buffer,sizeof(buffer),"%s:%d:xiaolu\n",msg,cnt);
   // fputs(msg,fp);
  // fprintf(stdout,"%s:%d:xiaolu\n",msg,cnt);
 //  printf("%s",buffer);
 //   cnt--;
//  }
//bi//n/BUFSIZn/  fclose(fp);
//  return 0;
//}
